#include "bmpeditor.h"
#include "spritemonster.h"

bool BMPEditor::loadMethod(const char * a_path)
{
	BitMaP * bmp = BitMaP::load(a_path);
	if(bmp && bmp->isBMP())
	{
		bool setThisBitmap = !m_bmp;
		if(m_bmp)
		{
			Sprite * s = ((SpriteMonster*)getParent()->getParent())->getSprite();
			char * replacementProcessErr = s->replaceSourceImage(m_bmp, bmp);
			if(replacementProcessErr)
			{
				printf("error: %s\n", replacementProcessErr);
			}
			setThisBitmap = replacementProcessErr == 0;
		}
		if(setThisBitmap)
		{
			setBMP(bmp);
			return true;
		}
	}
	if(bmp)
		bmp->release();
	return false;
}
